/**
 * @param {number} n
 * @param {number[]} startPos
 * @param {string} s
 * @return {number[]}
 */
 var executeInstructions = function(n, startPos, s) {
  const map = {
    'L':[0,-1],
    'R':[0,1],
    'U':[-1,0],
    'D':[1,0]
  }
  let ans = []
  for(let i = 0; i<s.length; i++){
    let [x,y] = startPos 
    let cnt = 0
    for(let j = i; j<s.length; j++){
      let now = s[j]
      let [dx, dy] = map[now]
      if((x + dx) < 0 || (x + dx) >= n || (y + dy) < 0 || (y + dy) >= n){
        break
      }
      x += dx
      y += dy
      cnt++
    }
    ans.push(cnt)
  }
  return ans
};